<!--供应商列表-->
<style lang="less" scoped>
.m-sech-wrap {
  padding-right:0.2rem;
}
.scroller-wrap {
  top:69px;
}
.list-cline {
  min-height: unset;
}
</style>

<template>
  <div class="contain">

    <!-- <div class="listhead-fix">
      <div class="m-sech-wrap displayflex">
        <div class="flex1">
          <router-link :to="{path:'/search',query: { type: 'supplier'}}" class="m-sech-box displayflex">
            <i class="iconfont icon-search"></i>
            <div class="flex1 m-sech-ipt">
              <div class="txt">{{sechTxt || '供应商名称'}}</div>
            </div>
          </router-link>
        </div>
      </div>
    </div> -->

    <scroller lock-x scrollbar-y use-pullup v-if="todolist.length>0" ref="Scroller" :pullup-config="ScrollerConfig" @on-pullup-loading="loadMore">
      <div>
        <div class="list-cwarp">
          <div class="list-cline" v-for="item in todolist">
            <div @click="gotoDet(item.guid)">
              <h2 class="tit ellipsis">{{item.ChineseName}}</h2>
              <!-- <p class="tip ellipsis">{{item.Province | province}}{{item.City | city}}{{item.District | district}}{{item.Address}}</p> -->
              <p class="list-contact">联系人：{{item.Contacts}}  {{item.ContactTel}}</p>
              <!-- <div class="tag" v-if="item.OrgRank">{{item.OrgRank | rank}}{{item.OrgGrade | grade}}</div> -->
            </div>
              <div class="acpt-list-btn">
              <div class="btn mb10" @click="gotoGoodsDet(item.SDSupplierGUID)" >经营商品</div>
            </div>
          </div>
        </div>
      </div>
      <div v-if="noMore" class="loader-over">没有更多记录了</div>
    </scroller>
    <div class="noDate_page" v-if="todolist.length <= 0">
      <div class="noDate_icon"><i class="iconfont icon-null"></i></div>
      暂无数据！
    </div>
    <manage-footer :status='5'></manage-footer>
  </div>
</template>

<script>
import manageFooter from '@/components/core/footer/manage.footer.vue';
// import indexTab from '@/components/core/header/index_tab.vue';
export default {
  components: {
    manageFooter
  },
  data() {
    return {
      sechTxt:'',
      todolist: [],
      totalRecords: 0,
      PageIndex: 1,
      PageSize:6,
      noMore:false,
      query: [],
      ScrollerConfig: {
        content: '上拉加载',
        downContent: '上拉加载',
        height: 0,
        loadingContent: '加载中...',
        upContent: '上拉加载',
      }
    }
  },
  computed: {
    userinfo(){
      return localStorage.getItem('userinfo') === null?null:JSON.parse(localStorage.getItem('userinfo'));
    }
  },
  created() {
    this.sechTxt = sessionStorage.sechtxt;
    this.getData(1);
  },
  mounted() {
    this.$nextTick(function() {

    })
  },
  methods: {
    createUser(itemGuid){
      this.$router.push({ path: 'customReguser', query: { Guid: itemGuid } })
    },
    editUser(itemGuid, edit){
      this.$router.push({ path: 'customReguser', query: { Guid: itemGuid, mode: edit} })
    },

    loadMore () {
      this.getData();
    },
    getData() {
      let query = {

        };
      if (sessionStorage.getItem('sechtxt')) {
        sessionStorage.removeItem('sechtxt');
      }
      this.Ajax.post('wxh/excsupplier/query', query).then((resp) => {
        if (resp.errorCode==0) {
          this.totalRecords = resp.data.length;
          this.todolist=resp.data;
          this.ScrollControl();
        //   if(resp.data.length > 0){
        //     this.PageSize++;
        //     this.todolist = this.todolist.concat(resp.Datas);
        //     this.ScrollControl();
        //   };
          
        } else {
          this.Toast({
            message: resp.message || '操作异常，请稍后重试',
          });
        };
      });
    },
    gotoDet(id) {
        this.$router.push({ 
          path: '/SupplierLic/mySupplierInfo', 
          query: { 
            Guid: id
          } 
        })
    },
    gotoGoodsDet(id) {
        this.$router.push({ 
          path: '/GoodsLic', 
          query: { 
            Guid: id
          } 
        })
    },
    call(tel){
       window.location.href=`tel://${tel}`;
    },
    ScrollControl(){
      if(this.totalRecords <= this.PageSize){
        this.ScrollerConfig.content = '';
        this.noMore = true;
        this.$nextTick(() => {
          this.$nextTick(() => {
            this.$refs.Scroller.disablePullup();
          });
        });
      }

      if(this.todolist.length > 0 && this.$refs.Scroller){
        this.$nextTick(() => {
          this.$nextTick(() => {
            this.$refs.Scroller.donePullup();
          });
        });
      }

      if (this.totalRecords == this.todolist.length) {
        this.$nextTick(() => {
          this.$nextTick(() => {
            this.$refs.Scroller.disablePullup();
            this.noMore = true;
          });
        });
      }
    }
  }
}
</script>